//
//  DemandDetailViewController.swift
//  PropertyCommunity
//
//  Created by benwang on 2021/7/1.
//

import UIKit
import RxCocoa
import RxSwift

class DemandDetailViewController: UIViewController {
  private let disposeBag = DisposeBag()
  var type = DemandStatus.unpaidFee

  override func viewDidLoad() {
    super.viewDidLoad()

    // Do any additional setup after loading the view.

    opacityNavigationBar(color: .white)

    view.backgroundColor = .designKit.secondaryBackground

    view.addSubview(tableView)
    tableView.snp.makeConstraints { make in
      make.top.equalTo(view.safeAreaLayoutGuide.snp.top)
      make.left.right.equalToSuperview()
      make.bottom.equalToSuperview()
    }

    if type == .unpaidFee {
      title = "立即缴费"
      let bottomView = R.nib.bottomButtonContentView(owner: self)!
      bottomView.button.setTitle("催缴（0次）", for: .normal)
      view.addSubview(bottomView)
      bottomView.snp.makeConstraints { make in
        make.right.left.bottom.equalToSuperview()
        make.height.equalTo(88)
      }
      bottomView.button.rx.tap
        .subscribe(onNext: {
          //            self.jumpToPaid()
        })
        .disposed(by: disposeBag)
    } else {
      title = "缴费详情"
    }
  }


  private lazy var tableView: UITableView = {
    let tb = UITableView(frame: .zero, style: .plain)
    tb.delegate = self
    tb.dataSource = self
    tb.separatorStyle = .none
    tb.register(UINib(resource: R.nib.demandDetailContentCell), forCellReuseIdentifier: "id")
    tb.tableFooterView = UIView(frame: CGRect(x: 0, y: 0, width: 0, height: 0))
    tb.contentInset = .init(top: 8, left: 0, bottom: 8, right: 0)
    tb.backgroundColor = .designKit.secondaryBackground
    return tb
  }()

  /*
   // MARK: - Navigation

   // In a storyboard-based application, you will often want to do a little preparation before navigation
   override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
   // Get the new view controller using segue.destination.
   // Pass the selected object to the new view controller.
   }
   */

}

extension DemandDetailViewController: UITableViewDelegate, UITableViewDataSource {

  func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return 1
  }

  func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    let cell = tableView.dequeueReusableCell(withIdentifier: "id", for: indexPath)
    return cell
  }
}
